<?php
include_once '/var/www/html/new/com.inc.php';
include("/var/www/html/new/conf/yd.le.je");
$ydle=new yd_go_sql();
$ydle->connect(); 
$id=$_REQUEST['id'];
if($_REQUEST['data-state']=='标记为已发布'){
    if(count($id)<3){
         echo "<script>alert('请选择三条路线!');parent.window.location='travelManage.html';</script>";
        exit;
    }elseif(count($id)>3){
         echo "<script>alert('路线不能多于三条!');parent.window.location='travelManage.html';</script>";
        exit;
    }else{
        for($i=0;$i<count($id);$i++){
            $time=date('Y-m-d h:i:s');
            $sql="update uu_tra_route set status='1',edit_date='$time' where id=$id[$i]";
            $res=$GLOBALS['ydle']->query($sql);
        }
        if($res){
             echo "<script>alert('发布成功!');parent.window.location='travelManage.html';</script>";
            }else{
             echo "<script>alert('发布失败!');parent.window.location='travelManage.html';</script>";
            }
    }
}elseif($_REQUEST['data-state']=='删除'){
    if(count($id)<1){
         echo "<script>alert('至少选择一条路线!');parent.window.location='travelManage.html';</script>";
         exit;
    }else{
        for($i=0;$i<count($id);$i++){
            $sql="delete from uu_tra_route where id=$id[$i]";
            $res=$GLOBALS['ydle']->query($sql);
            
        }
        if($res){
             echo "<script>alert('删除成功!');parent.window.location='travelManage.html';</script>";
            }else{
              echo "<script>alert('删除失败!');parent.window.location='travelManage.html';</script>";
            }
        }
    }

?>